import { onMounted, onUnmounted } from 'vue';

/**
 * document click hook
 * @param initExe
 * @param handle
 */
export default function useDocumentClick(handle: Function = () => {}) {
  const onClick = () => {
    handle && handle();
  };

  onMounted(() => {
    document.addEventListener('click', onClick);
  });

  onUnmounted(() => {
    document.removeEventListener('click', onClick);
  });
}
